import {BrowserModule} from '@angular/platform-browser';
import {ErrorHandler, NgModule} from '@angular/core';
import {IonicApp, IonicErrorHandler, IonicModule} from 'ionic-angular';
import {Toast} from '@ionic-native/toast';
import {Network} from '@ionic-native/network';
import {ModalController} from 'ionic-angular';
import {HTTP} from "@ionic-native/http";

import {Utils} from '../providers/Utils';
import {NativeService} from '../providers/NativeService';
import {Logger} from '../providers/Logger';
import {HttpService} from '../providers/HttpService';
import {GlobalData} from '../providers/GlobalData';


import {MyApp} from './app.component';
import {HomePage} from '../pages/home/home';
import {ListPage} from '../pages/list/list';
import {LoginPage} from "../pages/login/login";
import {StatusBar} from '@ionic-native/status-bar';
import {SplashScreen} from '@ionic-native/splash-screen';


import {FUNDEBUG_API_KEY, IS_DEBUG} from '../providers/Constants';


import * as fundebug from 'fundebug-javascript';
import {ComponentsModule} from "../components/components.module";
import {NewsDetailsPage} from "../pages/home/news-details";

fundebug.apikey = FUNDEBUG_API_KEY;
fundebug.releasestage = IS_DEBUG ? 'development' : 'production'; // 应用开发阶段，development:开发;production:生产
fundebug.silent = false; // 如果暂时不需要使用Fundebug，将silent属性设为true

export class FunDebugErrorHandler implements ErrorHandler {
  handleError(err: any): void {
    fundebug.notifyError(err);
    console.error(err);
  }
}

@NgModule({
  declarations: [
    MyApp,
    HomePage,
    ListPage,
    LoginPage,
    NewsDetailsPage,
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp),
    ComponentsModule
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,
    ListPage,
    LoginPage,
    NewsDetailsPage,
  ],
  providers: [
    StatusBar,
    SplashScreen,
    Toast,
    Network,
    ModalController,
    HTTP,
    Utils,
    Logger,
    NativeService,
    GlobalData,
    HttpService,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {
  constructor() {

  }

}
